
//
//  TrainHeadView.m
//  SpiritWalk
//
//  Created by shange1999 on 16/3/14.
//  Copyright © 2016年 王鑫. All rights reserved.
//

#import "TrainHeadView.h"



@implementation TrainHeadView

-(void)setHeadReceiveModel:(TrainDTVcHeadModel *)headReceiveModel{
    if (!_headReceiveModel) {
        _headReceiveModel=headReceiveModel;
        [self.backImage sd_setImageWithURL:[NSURL URLWithString:self.headReceiveModel.subject_pic]];
         self.subject_name.text =_headReceiveModel.subject_name;
        
        
            if ([_headReceiveModel.traning_difficult isEqualToString:@"1"]) {
                self.traning_difficult.text = @"初级";
            }else if ([self.receiveDic[@"traning_difficult"] isEqualToString:@"2"]){
                self.traning_difficult.text = @"中级";
            }else{
                self.traning_difficult.text = @"高级";
            }
            self.traning_day.text =[NSString stringWithFormat:@"锻炼%@天",_headReceiveModel.traning_day];
            self.traning_site.text=[NSString stringWithFormat:@"部位%@",_headReceiveModel.traning_site];
        self.desc.numberOfLines = 0;
            self.desc.text = _headReceiveModel.desc;
    }
}

-(id)initWithFrame:(CGRect)frame{
    self =[super initWithFrame:frame];
    if (self) {
        self.backImage =[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
//        self.backImage.backgroundColor =[UIColor yellowColor];
       [self addSubview:self.backImage];
    
        self.subject_name =[UILabel new];
        self.subject_name.textColor =[UIColor whiteColor];
//        self.subject_name .backgroundColor=[UIColor redColor];
        [self addSubview:self.subject_name];
        [self.subject_name mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).offset(10);
            make.left.equalTo(self).offset(10);
            make.right.equalTo(self).offset(-10);//              make.size.mas_equalTo(CGSizeMake(350, 50));
           make.height.mas_equalTo(50);//蓝色view的高度为50
        }];
     [self.subject_name.superview layoutIfNeeded];//强制绘制
        
        self.traning_difficult =[UILabel new];
         self.traning_difficult.textColor =[UIColor whiteColor];
//        self.traning_difficult.backgroundColor =[UIColor redColor];
        [self.backImage addSubview:self.traning_difficult];
        [self.traning_difficult mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).offset(75);
            make.left.equalTo(self).offset(10);
            make.size.mas_equalTo(CGSizeMake(80, 30));
        }];
//
        self.traning_day =[UILabel new];
         self.traning_day.textColor =[UIColor whiteColor];
//        self.traning_day.backgroundColor =[UIColor redColor];
        [self addSubview:self.traning_day];
        [self.traning_day mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).offset(75);
            make.left.equalTo(self).offset(120);
            make.size.mas_equalTo(CGSizeMake(80, 30));
        }];
//
        self.traning_site =[UILabel new];
         self.traning_site.textColor =[UIColor whiteColor];
//        self.traning_site.backgroundColor =[UIColor redColor];
        [self addSubview:self.traning_site];
        [self.traning_site mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).offset(75);
            make.left.equalTo(self).offset(230);
            make.size.mas_equalTo(CGSizeMake(80, 30));
        }];
//
        self.desc =[UILabel new];
         self.desc.numberOfLines = 0;
         self.desc.textColor =[UIColor whiteColor];
//        self.desc.backgroundColor =[UIColor redColor];
        [self addSubview:self.desc];
        [self.desc mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.top.equalTo(self).offset(150);
            make.left.equalTo(self).offset(10);
            make.right.equalTo(self).offset(-10);
            make.height.mas_equalTo(80);//蓝色view的高度为50
        }];

    }
    return self;
}
















/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
